﻿Imports BUS, DTO
Public Class frmCapNhatThamSo

    Sub LoadBangThamSo()
        Dim tsbus As New ThamSoBUS()
        Dim tsDto As New ThamSoDTO()
        tsDto = tsbus.LayThongtin()

        DataGridView_DanhSachThamSo.Item(0, 0).Value = tsDto.TuoiToiThieu
        DataGridView_DanhSachThamSo.Item(1, 0).Value = tsDto.TuoiToiDa
        DataGridView_DanhSachThamSo.Item(2, 0).Value = tsDto.ThoiHanThe
        DataGridView_DanhSachThamSo.Item(3, 0).Value = tsDto.NamXuatBan
        DataGridView_DanhSachThamSo.Item(4, 0).Value = tsDto.SoLuongSachMuonToiDa
        DataGridView_DanhSachThamSo.Item(5, 0).Value = tsDto.SoNgayMuonSachToiDa
        DataGridView_DanhSachThamSo.Item(6, 0).Value = tsDto.TienPhat

    End Sub


    Private Sub frmCapNhatThamSo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadBangThamSo()
    End Sub

    Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click
        Dim sql As String = "update THAMSO set TuoiToiThieu = " & DataGridView_DanhSachThamSo.Item(0, 0).Value
        sql = sql & " , TuoiToiDa = " & DataGridView_DanhSachThamSo.Item(1, 0).Value
        sql = sql & " , ThoiHan = " & DataGridView_DanhSachThamSo.Item(2, 0).Value
        sql = sql & " , NamXuatBan = " & DataGridView_DanhSachThamSo.Item(3, 0).Value
        sql = sql & " , SoSachMuonToiDa = " & DataGridView_DanhSachThamSo.Item(4, 0).Value
        sql = sql & " , SoNgayMuonToiDa = " & DataGridView_DanhSachThamSo.Item(5, 0).Value
        sql = sql & " , TienPhatMotNgayTre = " & DataGridView_DanhSachThamSo.Item(6, 0).Value
        'MessageBox.Show(sql)
        Dim tsbus As New ThamSoBUS()
        Dim kq As Integer = tsbus.CapNhatThamSo(sql)

        If kq = 1 Then
            MessageBox.Show("Cập nhật thành công !")
        Else
            MessageBox.Show("Cập nhật thất bại !")

        End If

    End Sub
End Class